package TrueTopic;

import java.util.Scanner;

public class BIN {

    static int[] id = new int[1000];
    static int n = 0;

    static void init() {    // 初始化id值
        for (int i = 1; i <= n; i++)
            id[i] = i;
    }

    static void unionNode(int p, int q) {    // 合并节点
        int temp = id[p];
        if (temp != id[q])
            for (int i = 1; i <= n; i++) {
                if (id[i] == temp)
                    id[i] = id[q];
            }
    }

    static int find(int i) {    // 查找节点集合
        return id[i];
    }

    static Boolean connected(int p, int q) {    // 判断节点是否连接
        return find(p) == find(q);
    }

    public static void main(String[] args) {
        int m, p, x, y;
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        p = scanner.nextInt();
        init();
        for (int i = 0; i < m; i++) {
            x = scanner.nextInt();
            y = scanner.nextInt();
            unionNode(x, y);
        }
        for (int i = 0; i < p; i++) {
            x = scanner.nextInt();
            y = scanner.nextInt();
            if (connected(x, y))
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }
}